﻿
using System.Collections.Generic;

namespace AlibabaCloud.CallCenter
{
    public class Common
    {
        //系统必须参数，KeyID、KeySecret和短信签名
        private readonly static string accessKeyId = "";//
        private readonly static string accessKeySecret = "";//

        /// <summary>
        /// 创建联络客户端
        /// </summary>
        public static AlibabaCloud.OpenApiClient.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            config.Endpoint = "ccc.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.OpenApiClient.Client(config);
        }
        public static AlibabaCloud.OpenApiClient.Models.Params CreateApiInfo(string action, string version = "2020-07-01")
        {
            AlibabaCloud.OpenApiClient.Models.Params params_ = new AlibabaCloud.OpenApiClient.Models.Params
            {
                // 接口名称
                Action = action,
                // 接口版本
                Version = version,
                // 接口协议
                Protocol = "HTTPS",
                // 接口 HTTP 方法
                Method = "POST",
                AuthType = "AK",
                Style = "RPC",
                // 接口 PATH
                Pathname = "/",
                // 接口请求体内容格式
                ReqBodyType = "json",
                // 接口响应体内容格式
                BodyType = "json",
            };
            return params_;
        }

        public static Dictionary<string,object> GetActionResult(string action, string version = "2020-07-01", Dictionary<string, object> query = null)
        {
            AlibabaCloud.OpenApiClient.Client client = CreateClient();
            AlibabaCloud.OpenApiClient.Models.Params params_ = CreateApiInfo(action, version);
            // runtime options
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            AlibabaCloud.OpenApiClient.Models.OpenApiRequest request = new AlibabaCloud.OpenApiClient.Models.OpenApiRequest
            {
                Query = AlibabaCloud.OpenApiUtil.Client.Query(query),
            };

            // 复制代码运行请自行打印 API 的返回值
            // 返回值实际为 Map 类型，可从 Map 中获得三类数据：响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
            return client.CallApi(params_, request, runtime);
        }
    }
}
